package com.gsdata.sdk;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @title Demo
 * @author JJC
 * @createDate 2017年7月20日
 * @version 1.0
 * @details 
 */
public class Demo {
	private static final String METHOD_GET = "GET";
	private static final String METHOD_POST = "POST";
	private static final String TestURL = "http://api.gsdata.cn/weixin/v1/tests";
	private static final String WebcatArticlesURL = "http://api.gsdata.cn/weixin/v1/articles";
	
	//微信日/周/月榜单
	//必填参数1：groupid分组信息
	private static final String WebcatRanksURL = "http://api.gsdata.cn/weixin/v1/ranks";
	//必填参数2：groupid分组信息 start_date 出榜的日期(格式：yyyy-MM-dd),每周的周六，如2016-01-02,2016-01-09
	private static final String WebcatRanksWeeksURL = "http://api.gsdata.cn/weixin/v1/ranks/weeks";
	//必填参数1：groupid分组信息 
	//选填：start_date 出榜的月份(格式：yyyy-MM)如2017-01,2017-03
	private static final String WebcatRanksMonthsURL = "http://api.gsdata.cn/weixin/v1/ranks/months";
	
	
	// 开放平台(open.gsdata.cn/user)中我的应用可见 app_key 和 app_id
	private static final String APPKEY = "0dk_IZazxtGbS9VB9-SGGbl2c2_B0xP6";
	private static final String APPID = "548";
	
	public static void main(String[] args) {
		//请求参数
		Map<String , Object> params = new HashMap<String , Object>();
		params.put("time", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
		params.put("s", System.currentTimeMillis());
		//初始化SDK
		SDK sdkGet = new SDK(METHOD_GET, TestURL , APPKEY , APPID);
		String result = null;
		try {
			//发送测试GET请求
			result = sdkGet.send(params,false);
			System.out.println(result);
			
			//初始化SDK
//			SDK sdkPost = new SDK(METHOD_POST, URL , APPKEY , APPID);
			//发送测试POST请求
			//若发送json格式数据，请设置true
//			result = sdkPost.send(params,false);
//			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
